import request from "./request";
import type { resData } from "@/views/goods-manage/type";
function uploads(path: any, data: any): Promise<resData> {
    const formData = new FormData();
    for (let i = 0; i < data.imageList.length; i++) {
        formData.append('imageURLs[]', data.imageList[i]);
    }
    for (let i = 0; i < data.files.length; i++) {
        formData.append('files[]', data.files[i]);
    }
    if (data.deleteList) {
        for (let i = 0; i < data.deleteList.length; i++) {
            formData.append('deleteURLs[]', data.deleteList[i]);
        }
    }
    formData.append('id', data.id);
    formData.append('content', data.content);
    formData.append('category', data.category);
    formData.append('username', data.username);
    formData.append('avatar', data.avatar);
    formData.append('name', data.name);


    return request
        .post(path, formData, {
            headers: {
                "Content-Type": "multipart/form-data",
            },
        })

}
export default uploads